﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Web.UI;

namespace olierFrm.WebFormDev.StdQuery
{
    public class HeaderRowTemplate : ITemplate
    {

        public void InstantiateIn(System.Web.UI.Control container)
        {
            var FieldName = ((DevExpress.Web.ASPxGridView.GridViewDataColumn)(((DevExpress.Web.ASPxClasses.TemplateContainerBase)(((DevExpress.Web.ASPxGridView.GridViewHeaderTemplateContainer)(container)))).DataItem)).FieldName;
            //var dd = DBFrm.FrameWork.DataDictornary.DataDictionary.FindByFieldName(FieldName);
            //container.Controls.Add(new LiteralControl(dd == null ? FieldName : dd.First().Value.DisplayLabel));
            //var dataItemContainer = (DevExpress.Web.ASPxGridView.GridViewDataColumn)container;
            var dtSource = (DataTable)((DevExpress.Web.ASPxGridView.GridViewHeaderTemplateContainer)(container)).Grid.DataSource;
            /*
            #region 处理隐藏字段
            var hideColumn = dtSource.GetHideColumn();
            if (hideColumn != null)
            {
                if (hideColumn.Contains(FieldName)) return;
            }
            #endregion
            */
            container.Controls.Add(new LiteralControl(DataBinder.GetDataItem(container).ToString()));
        }
    }
}
